package com.itheima.demo04_sealed;

/**
 * 目标： JEP 360 : Sealed Classes (Preview) 密封的类和接口（预览）
 */

// 人类
public sealed class Person permits Teacher, Student, SportMan, Doctor { }

// 老师
final class Teacher extends Person {}

// 学生
sealed class Student extends Person permits MiddleSchoolStudent, UniversityStudent {}
// 中学生
final class MiddleSchoolStudent extends Student {}
// 大学生
final class UniversityStudent extends Student {}

// 运动员
non-sealed class SportMan extends Person {}
// 医生
non-sealed class Doctor extends Person {}
// 乒乓球运动员
class PingPongMan extends SportMan { }